package com.hr.reactive.common;

import com.github.javafaker.Faker;
import org.reactivestreams.Subscriber;
import reactor.core.publisher.Mono;

/**
 * @author huran
 */
public class Utils {
    private static final Faker faker=Faker.instance();
    /**
     * 公开我们的订阅者
     *
     * @param <T>
     * @return
     */
    public static <T> Subscriber<T> subscriber() {
        return new DefaultSubscriber<>("");
    }

    public static <T> Subscriber<T> subscriber(String name) {
        return new DefaultSubscriber<>(name);
    }

    public static void sleepSeconds(int time){
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
    public static Faker faker(){
        return faker;
    }
    public static void main(String[] args) {
        Mono<Integer> just = Mono.just(1);
        just.subscribe(subscriber());
        just.subscribe(subscriber("胡冉"));
    }
}
